<%@ page import="com.kgc.service.NewsService" %>
<%@ page import="com.kgc.service.impl.NewsServiceImpl" %>
<%@ page import="com.kgc.entity.News" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/3/5
  Time: 20:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>新闻列表页</title>
</head>
<body>
<jsp:useBean id="newsService" class="com.kgc.service.impl.NewsServiceImpl"></jsp:useBean>
<%
    //在jsp页面里显示全部的新闻信息
    //NewsService newsService=new NewsServiceImpl();
    List<News> newsList = newsService.queryNewsAll();

%>
<table>
    <tr>
        <th>新闻编号</th>
        <th>新闻分类</th>
        <th>新闻标题</th>
        <th>新闻摘要</th>
        <th>新闻内容</th>
        <th>新闻图片</th>
        <th>新闻作者</th>
        <th>创建日期</th>
        <th>修改日期</th>
    </tr>
<%
    //用增强型for循环遍历集合
    for(News news:newsList){
%>
    <tr>
        <td><%=news.getId()%></td>
        <td><%=news.getCategoryId()%></td>
        <td><%=news.getTitle()%></td>
        <td><%=news.getSummary()%></td>
        <td><%=news.getContent()%></td>
        <td><%=news.getPicPath()%></td>
        <td><%=news.getAuthor()%></td>
        <td><%=news.getCreateDate()%></td>
        <td><%=news.getModifyDate()%></td>
    </tr>
<%
    }
%>

</table>
<jsp:include page="test.jsp"></jsp:include>
</body>
</html>
